<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%--
    Document   : admin
    Created on : Sep 30, 2010, 12:09:20 PM
    Author     : ATan1
--%>
<logic:present name="data_fullaccess">
<script type="text/javascript">
    function geneShowHide(){
        // Set up snp select dialog
        $("#geneShowHide").dialog({
            autoOpen: true,
            modal: true,
            buttons: {
            }
        });
    }
    function updateGeneLinks(){
        // Set up snp select dialog
        $("#updateGeneLinks").dialog({
            autoOpen: true,
            modal: true,
            buttons: {
                Ok: function() {
                    $.ajax({
                        url: "adminUpdateGeneLinks.do",
                        success: function(){
                            $('#loadingWait').dialog("close");
                            $('#done').dialog({
                                autoOpen:true,
                                modal:true,
                                buttons: {
                                    Ok: function() {
                                        $(this).dialog("close");
                                    }
                                }
                            });
                        }
                    });
                    $(this).dialog("close");
                    $('#loadingWait').dialog({
                        autoOpen: true,
                        modal: true,
                        buttons: {
                            Cancel: function() {
                                $(this).dialog("close");
                            }
                        }
                    });
                },
                Cancel: function() {
                    $(this).dialog("close");
                }
            }
        });
    }
    function updateGeneAlias(){
        // Set up snp select dialog
        $("#updateGeneAlias").dialog({
            autoOpen: true,
            modal: true,
            buttons: {
                Ok: function() {
                    $.ajax({
                        url: "adminUpdateGeneAlias.do",
                        success: function(){
                            $('#loadingWait').dialog("close");
                            $('#done').dialog({
                                autoOpen:true,
                                modal:true,
                                buttons: {
                                    Ok: function() {
                                        $(this).dialog("close");
                                    }
                                }
                            });
                        }
                    });
                    $(this).dialog("close");
                    $('#loadingWait').dialog({
                        autoOpen: true,
                        modal: true,
                        buttons: {
                            Cancel: function() {
                                $(this).dialog("close");
                            }
                        }
                    });
                },
                Cancel: function() {
                    $(this).dialog("close");
                }
            }
        });
    }
    function updateKeggPath(){
        // Set up snp select dialog
        $("#updateKeggPath").dialog({
            autoOpen: true,
            modal: true,
            buttons: {
                Ok: function() {
                    $.ajax({
                        url: "adminUpdateKeggPathways.do",
                        success: function(){
                            $('#loadingWait').dialog("close");
                            $('#done').dialog({
                                autoOpen:true,
                                modal:true,
                                buttons: {
                                    Ok: function() {
                                        $(this).dialog("close");
                                    }
                                }
                            });
                        }
                    });
                    $(this).dialog("close");
                    $('#loadingWait').dialog({
                        autoOpen: true,
                        modal: true,
                        buttons: {
                            Cancel: function() {
                                $(this).dialog("close");
                            }
                        }
                    });
                },
                Cancel: function() {
                    $(this).dialog("close");
                }
            }
        });
    }
    function select() {
        switch(parseInt($("#searchSelect").val()))
        {
            case 1:
                selectSnp();
                break;
            case 2:
                selectGene();
                break;
        }
    }
    function switchHandler() {
        $("#searchSelect").change(function() {
            select();
        });
        select();
    }
    function selectSnp() {
        reset();
        $("#selectionTip").html("Type one RS Number per line.");
        $("#snpDropdown").attr("selected", "selected");
        $("#geneSet").css("display", "none");
        $("#snpSet").css("display", "");
    }
    function selectGene() {
        reset();
        $("#selectionTip").html("Type one Gene Name OR Entrez Gene ID (NCBI ID) per line");
        $("#geneDropdown").attr("selected", "selected");
        $("#snpSet").css("display", "none");
        $("#geneSet").css("display", "");
    }
    function reset() {
        $("#select option:selected").removeAttr("selected");
        $("[id$=Dropdown]").removeAttr("selected");
        $("[id$=Anchor]").removeClass("selected");
        $("[id$=Dt]").hide();
        $("[id$=Dd]").hide();
        $("#showAll").removeAttr("disabled");
    }
</script>
<html:errors property="move" />
<div id="loadingWait" class="content" style="display:none; text-align: center">
    Please Wait <br/>
    <img id="ajax-load" alt="Loading... Please Wait" src="images/ajax-loader.gif"/>
</div>
<div id="done" class="content" style="display:none; text-align:center">
    Done!
</div>
<div id="admin" class="content">
    <h2>Database Administrative Settings</h2>
    <dl>
        <dt><html:link onclick="geneShowHide(); switchHandler();" href="#">Show/Hide SNPs/Genes</html:link></dt>
        <dd>Copies SNPs and Genes from the Private set into different sets (eg. Public)</dd>
        <dt><html:link onclick="updateGeneLinks()" href="#">Update Gene Links</html:link></dt>
        <dd>Updates the links on the Gene Summary Page so it redirects to the proper locations</dd>
        <dt><html:link onclick="updateGeneAlias()" href="#">Update Gene Alias</html:link></dt>
        <dd>Updates the database's repository of different aliases for genes</dd>
        <dt><html:link onclick="updateKeggPath()" href="#">Update Kegg Pathways</html:link></dt>
        <dd></dd>
    </dl>



         <div id="geneShowHide" title="Show/Hide Genes/Snps" style="display:none">
            <table id="geneShowHideTable" cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td>
                        <html:errors property="search" />
                        <html:form action="moveGeneSnpSubmit">
                            <div>
                                <p>Copy&nbsp;
                                    <html:select styleId="searchSelect" property="searchSelect">
                                        <html:option styleId="snpDropdown" value="1">SNPs</html:option>
                                        <html:option styleId="geneDropdown" value="2">Genes</html:option>
                                    </html:select> to


                                    <html:select styleId="geneSet" property="geneSet" disabled="disabled" style="display:none">
                                    <logic:empty name="moveGeneSnpForm" property="geneSetLookUp">
                                        <html:option value="">No other sets found.</html:option>
                                    </logic:empty>
                                    <logic:notEmpty name="moveGeneSnpForm" property="geneSetLookUp">
                                        <html:options property="geneSetLookUp"/>
                                    </logic:notEmpty>
                                    </html:select>

                                    <html:select styleId="snpSet" property="snpSet">
                                    <logic:empty name="moveGeneSnpForm" property="snpSetLookUp">
                                        <html:option value="">No other sets found.</html:option>
                                    </logic:empty>
                                    <logic:notEmpty name="moveGeneSnpForm" property="snpSetLookUp">
                                        <html:options property="snpSetLookUp"/>
                                    </logic:notEmpty>
                                    </html:select>

                                </p>
                                <p id="selectionTip"></p>
                                <html:textarea property="searchText" styleId="searchText" rows="5" cols="20" style="width: 20em;" />
                                <html:submit property="submitType" value="Copy" />
                            </div>
                        </html:form>
                    </td>
                </tr>
            </table>
        </div>

        <div id="updateGeneLinks" title="Update Gene Links" style="display:none">
            <table id="updateGeneLinksTable" cellpadding="0" cellspacing="0" border="0">
                <tiles:insert name="pleaseWait"/>
            </table>
        </div>
        <div id="updateGeneAlias" title="Update Gene Alias" style="display:none">
            <table id="updateGeneAliasTable" cellpadding="0" cellspacing="0" border="0">
                <tiles:insert name="pleaseWait"/>
            </table>
        </div>
        <div id="updateKeggPath" title="Update Kegg Pathway" style="display:none">
            <table id="updateKeggPathTable" cellpadding="0" cellspacing="0" border="0">
                <tiles:insert name="pleaseWait"/>
            </table>
        </div>
    </div>
</logic:present>